#ifndef __GUI_H__
#define __GUI_H__

#include <glib.h>

#define IO_PIN_COUNT 38

#define PIN_IN          0x01
#define PIN_OUT         0x02
#define PIN_IN_OUT      0x03
#define PIN_A_IN        0x04
#define PIN_A_IN_DIF    0x08
#define PIN_A_OUT       0x10

struct TIoPinDefs 
  {
  unsigned int Pin;
  unsigned int Flags;
  unsigned int Zeile;
  unsigned int Spalte;
  const char *CfgName;
  const char *InName;
  const char *OutName;  
  const char *AnalogName;
  };

struct TIoPin
  {
  int Mode;  // 0 = Input
             // 1 = Output
             // 2 = Analog Output
             // 3 = Analog Input 
             // 4 = Analog Differential +
             // 5 = Analog Differential -
  gchar *Name;
  int In;
  int AIn;
  GtkWidget *OutWidget;
  GtkWidget *InBoxWidget;
  GtkWidget *InWidget;
  GtkWidget *AInBoxWidget;
  GtkWidget *AInWidget;
  GtkWidget *AOutBoxWidget;
  GtkWidget *AOutWidget;
  GtkWidget *ConfigBoxWidget;
  GtkWidget *ConfigWidget;

  GtkWidget *InNameWidget;
  GtkWidget *AInNameWidget;
  GtkWidget *AOutNameWidget;
  };


struct TConfig
  {
  int AdRef;
  int PwmSpeed1;
  int PwmSpeed2;
  };


extern struct TIoPin IoPin[IO_PIN_COUNT];
extern const struct TIoPinDefs IoPinDefs[];
extern struct TConfig Config;
extern guint RefreshTimerId;
extern char *CfgFileName;

  
void GuiInit(void);
void GuiDestroy(void);
void IoPinSetDefaultName(int pin_idx);
void GetConfigForPin(int pin_idx);
void GetConfigFromGui(void);
void SetConfigToGui(void);
void SetGuiShowing(int config);
gint RefreshMainWin(gpointer data);
GtkWidget *CreateMainWin(void);

#endif
